-
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
4.3: as const
looking for the identifier const in a generic class
#44292
Comments
What a strange issue. It's caused by a local AST walk we do in |
Following #43696 we now call |
Actually, it does appear that #43696 is the direct cause of this issue. For methods that have a type annotation, the changes in that PR cause Not too hard to fix, I'll put up a PR. |
BTW, here's a smaller repro: export class C<T> {
f(): void {
let one = 1 as const; // Error, but shouldn't be
}
}
new C<string>().f(); |
i also ran into this issue in my codebase, and was able to produce this repro case: export class A<T> {
public myMethod(): void {
const a = 'str' as const;
}
}
const a = new A();
export class B<T> extends A<
T
> {
public static staticMethod<T>(
): B<T> {
return new B();
}
} |
This can't be scheduled for TypeScript 4.3.2 because that was already shipped last week. |
Bug Report
We got a report that
as const
stopped being special case syntax from NordicSemiconductor/cloud-e2e-bdd-test-runner-js#188🔎 Search Terms
as const
4.3Cannot find name 'const'
🕗 Version & Regression Information
⏯ Playground Link
Workbench Repro
🙁 Actual behavior
Compiler error from bad lookup for
const
🙂 Expected behavior
No error
The text was updated successfully, but these errors were encountered: