Investigate removing the concept of object allocators
@rbuckton já está trabalhando nisso.
Desde 25/2/2023.
Avaliação
Esta issue ainda não foi avaliada.
Descrição
Today we have the concept of an "object allocator". This is basically a set of functions, each which returns a constructor function for a commonly used data structure in the compiler.
/** @internal */
export interface ObjectAllocator {
getNodeConstructor(): new (kind: SyntaxKind, pos: number, end: number) => Node;
getTokenConstructor(): new <TKind extends SyntaxKind>(kind: TKind, pos: number, end: number) => Token<TKind>;
getIdentifierConstructor(): new (kind: SyntaxKind.Identifier, pos: number, end: number) => Identifier;
getPrivateIdentifierConstructor(): new (kind: SyntaxKind.PrivateIdentifier, pos: number, end: number) => PrivateIdentifier;
getSourceFileConstructor(): new (kind: SyntaxKind.SourceFile, pos: number, end: number) => SourceFile;
getSymbolConstructor(): new (flags: SymbolFlags, name: __String) => Symbol;
getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type;
getSignatureConstructor(): new (checker: TypeChecker, flags: SignatureFlags) => Signature;
getSourceMapSourceConstructor(): new (fileName: string, text: string, skipTrivia?: (pos: number) => number) => SourceMapSource;
}
Why do this? Because for our batch compiler, TypeScript uses constructors with more bare-bones objects. For the most part, there are no members on the prototype, and we work purely with instance-set data.
On the other hand, the language service and TypeScript's API provides constructors that are attached to richer prototypes. For example, Nodes constructed by the language service have methods like getStart(), getEnd(), getSourceFile(), etc. These are partially for convenience and if my memory serves correctly, partially to power backwards-compatibility going back to TypeScript 1.0's tree API.
However, managing the two is slightly annoying, and creates layers of indirection. It would be nice to see if we can move away from this indirection and whether it can eliminate runtime overhead at all.
- Linguagem predominante
- Go
- Estrelas
- 111k
- Forks
- 14.4k
- Merge médio
- 1d 19h
- PRs com merge (30d)
- 117
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de microsoft/TypeScript
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
microsoft/TypeScript#64322 · 2 comentários · 1 reação · 2 responsáveis ·
-
Possible Improvement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
microsoft/TypeScript#64278 · 1 comentário · 1 reação ·
-
Docs
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
microsoft/TypeScript#64118 · 1 comentário ·
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
microsoft/TypeScript#64094 ·
-
Docs
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
microsoft/TypeScript#63959 · 5 comentários ·
Todas as issues de microsoft/TypeScript
Issues semelhantes
-
optimization optimization:agents-md-curator
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
githubnext/gh-aw-cao#13143 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
blinklabs-io/bursa#904 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
yanet-platform/ipfw-go#129 ·
-
bug confmap/provider/googlesecretmanagerprovider needs triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
open-telemetry/opentelemetry-collector-contrib#51273 · 2 comentários ·
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 90/100