-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Compile with --noImplicitThis #9580
Conversation
1. Add to various tsconfig.json 2. Add to Jakefile 3. Add annotations where needed. 4. Add workaround to shims.ts, which uses toplevel `this`.
The CI build pointed out that I failed to update the harness tsconfig.json -- Jake caught it because it uses the command line parameter instead of tsconfig.json |
@@ -1237,20 +1237,20 @@ namespace ts { | |||
getSignatureConstructor(): new (checker: TypeChecker) => Signature; | |||
} | |||
|
|||
function Symbol(flags: SymbolFlags, name: string) { | |||
function Symbol(this: Symbol, flags: SymbolFlags, name: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rakatyal just remembered your tslint rule would have issues with this because it can't distinguish between ts.Symbol
and Symbol
I tested that the shims workaround to obtain global |
@weswigham I updated Gulpfile.ts with some defaults for tasks that use gulp-typescript's settings object instead of a tsconfig. Unfortunately, the one I wanted, |
There's a patch at the top of the Gulpfile adding in options |
Got it -- I added them. |
Do you want to add |
@@ -2081,7 +2081,7 @@ namespace ts.server { | |||
const walkFns = { | |||
goSubtree: true, | |||
done: false, | |||
leaf: function (relativeStart: number, relativeLength: number, ll: LineLeaf) { | |||
leaf: function (this: ILineIndexWalker, relativeStart: number, relativeLength: number, ll: LineLeaf) { | |||
if (!f(ll, relativeStart, relativeLength)) { | |||
this.done = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of giving this function a this
type, can you not just replace this
with walkFns
(since it is just an object literal)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
Good idea, the output doesn't look much prettier than before, so I might be doing something wrong. |
Also, this PR fixes #9608. |
#9608 also mentions |
Never mind, the code's already there for |
@@ -1398,7 +1398,7 @@ namespace ts { | |||
return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = createTypeChecker(program, /*produceDiagnostics:*/ false)); | |||
} | |||
|
|||
function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult { | |||
function emit(this: Program, sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult { | |||
return runWithCancellationToken(() => emitWorker(this, sourceFile, writeFileCallback, cancellationToken)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to exchange this instance of this
for program
(which should be in scope)? Or is that excessive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmmmm...there's too much space between program
and emit
. I'm going to leave it. I don't think there's an easy solution, besides refactoring everything to use method syntax, which also has some bad side effects.
👍 With your discretion on my last comment. |
Please consider using an alternative to As far as I can understand, this is necessary to get the global object value without using |
@guncha would |
A PR is up at #11265 |
@sandersn it would fix the issue I've been seeing with Atom, thank you. |
Glad to hear it. This fix will ship with Typescript 2.1 |
--noImplicitThis
to various tsconfig.json (gulp uses tsconfig).--noImplicitThis
to Jakefile.this
.Also, fixes #9608