Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrated fixed test. #106

Merged
merged 10 commits into from
Nov 14, 2023

Conversation

dragomirtitian
Copy link

No description provided.

Signed-off-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
Signed-off-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
Signed-off-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
Signed-off-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
Signed-off-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
Signed-off-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
Signed-off-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
Signed-off-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
Signed-off-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
!!! error TS1005: ';' expected.
function function(): void { }
+
+!!! error TS9007: Declaration emit for this file requires type resolution. An explicit type annotation may unblock declaration emit.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a weird error, I guess we can detect this case and not print errors, on it WDYT?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is a good way to do this unless we are explicitly redetecting the syntax errors which is not something I would actually want to do. I will make a note to ask MS as well

+ Color,
+ Thing = Color
+ ~~~~~
+!!! error TS9007: Declaration emit for this file requires type resolution. An explicit type annotation may unblock declaration emit.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong. Color should get assigned 0 by the constEvaluate and thus Thing should also be zero if I try to recall the logic.


!!! error TS1146: Declaration expected.
+
+!!! error TS9007: Declaration emit for this file requires type resolution. An explicit type annotation may unblock declaration emit.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We seem to have a general problem on reporting around ill-formed syntax. What do you think is the right way to go?

if (isStringLiteralLike(node)) {
return factory.createStringLiteral(node.text);
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: would it be better to make line breaks more consistent?

options.declaration = true;
options.declarationMap = true;
const emitHost = createEmitDeclarationHost(options, sys);
export function transpileDeclaration(sourceFile: SourceFile, emitHost: IsolatedEmitHost) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please mark this @internal. Every file reading in the typescript.d.ts in will fail due to IsolatedEmitHost being internal.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should discuss this. Is this a fully internal API? I would rather mark IsolatedEmitHost as being public.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that's fine for me.

+
+ export const expr = (): void => {}
+ ~~~~
+!!! error TS9007: Declaration emit for this file requires type resolution. An explicit type annotation may unblock declaration emit.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't have triggered as it does have type annotation on the RHS.

  1. empty parameter.
  2. void as a return type.
    Triggering TS9009 should be enough.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Made a node to fix in a follow on PER

!!! error TS1182: A destructuring declaration must have an initializer.
~
!!! error TS7031: Binding element 'a' implicitly has an 'any' type.
+ ~
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is its own error - we should not report.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really do a lot of correlation between errors.

enum Foo {
a = b
+ ~
+!!! error TS9007: Declaration emit for this file requires type resolution. An explicit type annotation may unblock declaration emit.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, we seems not to support merged enum value assignments?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we don't they can merge across files which is something we definitely don't want.

// operand before -
var NUMBER1 = var NUMBER: any-; //expect error
+
+!!! error TS9007: Declaration emit for this file requires type resolution. An explicit type annotation may unblock declaration emit.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invalid syntax.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. This test is too invalid. I did not review all of them yet.

Signed-off-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
Comment on lines -128 to -130
if (diagnostics.length > 0) {
throw new Error(`Cannot transform file '${sourceFile.fileName}' due to ${diagnostics.length} diagnostics`);
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the throw here. The compiler does not generally throw errors on invalid code.

enum Foo {
a = b
+ ~
+!!! error TS9007: Declaration emit for this file requires type resolution. An explicit type annotation may unblock declaration emit.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we don't they can merge across files which is something we definitely don't want.

// operand before -
var NUMBER1 = var NUMBER: any-; //expect error
+
+!!! error TS9007: Declaration emit for this file requires type resolution. An explicit type annotation may unblock declaration emit.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. This test is too invalid. I did not review all of them yet.

!!! error TS1182: A destructuring declaration must have an initializer.
~
!!! error TS7031: Binding element 'a' implicitly has an 'any' type.
+ ~
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really do a lot of correlation between errors.

+
+ export const expr = (): void => {}
+ ~~~~
+!!! error TS9007: Declaration emit for this file requires type resolution. An explicit type annotation may unblock declaration emit.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Made a node to fix in a follow on PER

options.declaration = true;
options.declarationMap = true;
const emitHost = createEmitDeclarationHost(options, sys);
export function transpileDeclaration(sourceFile: SourceFile, emitHost: IsolatedEmitHost) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should discuss this. Is this a fully internal API? I would rather mark IsolatedEmitHost as being public.

!!! error TS1005: ';' expected.
function function(): void { }
+
+!!! error TS9007: Declaration emit for this file requires type resolution. An explicit type annotation may unblock declaration emit.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is a good way to do this unless we are explicitly redetecting the syntax errors which is not something I would actually want to do. I will make a note to ask MS as well

+ export {Foo};
+ export default function Example(): void {}
+ ~~~~~~~
+!!! error TS9009: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not on this PR, but we should look at improving this. Noted

constEnums.ts(33,5): error TS9007: Declaration emit for this file requires type resolution. An explicit type annotation may unblock declaration emit.
constEnums.ts(33,10): error TS2474: const enum member initializers must be constant expressions.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I was working on this one.

export module C {
export const enum E {
V1 = 1,
V2 = A.B.C.E.V1 | 100
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. we should porobably support it.

@dragomirtitian dragomirtitian merged commit 3023b9f into isolated-declarations Nov 14, 2023
1 check passed
@dragomirtitian dragomirtitian deleted the isolated-declarations-tests branch November 17, 2023 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants