Skip to content

Normative: Arbitrary module namespace identifier names - #49297

Closed
Jack Works (Jack-Works) wants to merge 6 commits into
microsoft:mainfrom
Jack-Works:ecma262-2154
Closed

Normative: Arbitrary module namespace identifier names#49297
Jack Works (Jack-Works) wants to merge 6 commits into
microsoft:mainfrom
Jack-Works:ecma262-2154

Conversation

@Jack-Works

@Jack-WorksJack Works (Jack-Works) commented May 29, 2022

Copy link
Copy Markdown
Contributor

Implementing tc39/ecma262#2154

@typescript-botTypeScript Bot (typescript-bot) added the For Milestone Bug PRs that fix a bug with a specific milestone label May 29, 2022
@typescript-botTypeScript Bot (typescript-bot) added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug and removed For Milestone Bug PRs that fix a bug with a specific milestone labels Apr 23, 2023
@Jack-Works

Copy link
Copy Markdown
ContributorAuthor

Made a full rewrite of this PR. Just get the compiler part to work. Will handle language service days later.

Comment threadsrc/compiler/checker.ts Outdated
let suggestedLib: string | undefined;
// Report missing lib first
if (nameArg) {
if (nameArg) {

@ExE-BossExE Boss (ExE-Boss)Apr 23, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: extraneous whitespace:

Suggested change
if(nameArg){
if(nameArg){

Comment threadsrc/compiler/checker.ts Outdated
@Jack-Works

Jack Works (Jack-Works) commented Jun 14, 2023

Copy link
Copy Markdown
ContributorAuthor

Hi, Daniel Rosenwasser (@DanielRosenwasser) I have a question. With this PR, it's possible to define members with names that cannot be an identifier on a Symbol.

exportconstenumInternalSymbolName{Call="__call",// Call signaturesConstructor="__constructor",// Constructor implementationsNew="__new",// Constructor signaturesIndex="__index",// Index signaturesExportStar="__export",// Module export * declarationsGlobal="__global",// Global self-referenceMissing="__missing",// Indicates missing symbolType="__type",// Anonymous type literal symbolObject="__object",// Anonymous object literal declarationJSXAttributes="__jsxAttributes",// Anonymous JSX attributes object literal declarationClass="__class",// Unnamed class expressionFunction="__function",// Unnamed function expressionComputed="__computed",// Computed property name declaration with dynamic nameResolving="__resolving__",// Indicator symbol used to mark partially resolved type aliasesExportEquals="export=",// Export assignment symbolDefault="default",// Default export symbol (technically not wholly internal, but included here for usability)This="this",}

I wonder if this PR gonna make programmers able to write code that breaks TS by declaring a symbol member that has the same name as an internal symbol, like

export{itemas"this"}// orexport{itemas"export=",itemas__new}

@DanielRosenwasser

Copy link
Copy Markdown
Member

I think the comment

Default export symbol (technically not wholly internal, but included here for usability)

is the key here, and the same applies to This. those symbols are just for comparisons in various places. If anything relied on this or default being special entities within a symbol table, they'd probably already be broken.

Maybe Wesley Wigham (@weswigham) or Gabriela Araujo Britto (@gabritto) can back me up on that statement though.

Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Uncommitted BugPR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@Jack-Works@DanielRosenwasser@ExE-Boss@typescript-bot