-
Notifications
You must be signed in to change notification settings - Fork 35
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
Activate strictBindCallApply and strictFunctionTypes compiler rules #2880
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,15 +14,15 @@ import {Arc} from './arc.js'; | |
import {DevtoolsConnection} from './debug/devtools-connection.js'; | ||
import {OuterPortAttachment} from './debug/outer-port-attachment.js'; | ||
import {Handle} from './handle.js'; | ||
import {ParticleSpec} from './particle-spec.js'; | ||
import {ParticleSpec, SerializedParticleSpec} from './particle-spec.js'; | ||
import {Particle} from './particle.js'; | ||
import * as recipeHandle from './recipe/handle.js'; | ||
import * as recipeParticle from './recipe/particle.js'; | ||
import {StorageProxy} from './storage-proxy.js'; | ||
import {SerializedModelEntry} from './storage/crdt-collection-model.js'; | ||
import {StorageProviderBase} from './storage/storage-provider-base.js'; | ||
import {Type} from './type.js'; | ||
import {PropagatedException} from './arc-exceptions.js'; | ||
import {Type, TypeLiteral} from './type.js'; | ||
import {PropagatedException, SerializedPropagatedException} from './arc-exceptions.js'; | ||
|
||
enum MappingType {Mapped, LocalMapped, RemoteMapped, Direct, ObjectMap, List, ByLiteral} | ||
|
||
|
@@ -32,15 +32,25 @@ interface MappingInfo { | |
redundant?: boolean; | ||
value?: MappingInfo; | ||
key?: MappingInfo; | ||
converter?: Literalizer; | ||
converter?: Literalizer | LiteralizerParticleSpec | LiteralizerPropagatedException; | ||
identifier?: boolean; | ||
ignore?: boolean; | ||
} | ||
|
||
// TODO(shans): are there better types that I can use for this? | ||
interface Literalizer { | ||
prototype: {toLiteral: () => {}}; | ||
fromLiteral: ({}) => {}; | ||
prototype: {toLiteral: () => TypeLiteral}; | ||
fromLiteral: (typeliteral: TypeLiteral) => Type; | ||
} | ||
|
||
interface LiteralizerParticleSpec { | ||
prototype: {toLiteral: () => SerializedParticleSpec}; | ||
fromLiteral: (spec: SerializedParticleSpec) => ParticleSpec; | ||
} | ||
|
||
interface LiteralizerPropagatedException { | ||
prototype: {toLiteral: () => SerializedPropagatedException}; | ||
fromLiteral: (exception: SerializedPropagatedException) => PropagatedException; | ||
} | ||
|
||
const targets = new Map<{}, Map<string, MappingInfo[]>>(); | ||
|
@@ -67,7 +77,7 @@ function Mapped(target: {}, propertyKey: string, parameterIndex: number) { | |
set(target.constructor, propertyKey, parameterIndex, {type: MappingType.Mapped}); | ||
} | ||
|
||
function ByLiteral(constructor: Literalizer) { | ||
function ByLiteral(constructor: Literalizer | LiteralizerParticleSpec | LiteralizerPropagatedException) { | ||
return (target: {}, propertyKey: string, parameterIndex: number) => { | ||
const info: MappingInfo = {type: MappingType.ByLiteral, converter: constructor}; | ||
set(target.constructor, propertyKey, parameterIndex, info); | ||
|
@@ -415,7 +425,7 @@ export abstract class PECOuterPort extends APIPort { | |
UIEvent(@Mapped particle: recipeParticle.Particle, @Direct slotName: string, @Direct event: {}) {} | ||
SimpleCallback(@RemoteMapped callback: number, @Direct data: {}) {} | ||
AwaitIdle(@Direct version: number) {} | ||
StartRender(@Mapped particle: recipeParticle.Particle, @Direct slotName: string, @ObjectMap(MappingType.Direct, MappingType.Direct) providedSlots: {[index: string]: string}, @List(MappingType.Direct) contentTypes: string[]) {} | ||
StartRender(@Mapped particle: recipeParticle.Particle, @Direct slotName: string, @ObjectMap(MappingType.Direct, MappingType.Direct) providedSlots: Map<string, string>, @List(MappingType.Direct) contentTypes: string[]) {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that the new checks caught this type mismatch. (Should be Map<string,string>) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! |
||
StopRender(@Mapped particle: recipeParticle.Particle, @Direct slotName: string) {} | ||
|
||
abstract onRender(particle: recipeParticle.Particle, slotName: string, content: string); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is a little hacky, but describes the current usage. Should ParticleSpec/PropagatedException implement Type/TypeLiteral instead?
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.
better to templatize literalizer on the literal type.
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.
I tried to parameterize Literalizer, but none of them survived the use of decorators with any fidelity.
I also started down the path of creating a new Literalizable interface but ran into the same issues with adding Types to EnityType (namely lack of static methods in interfaces microsoft/TypeScript#14600) Especially with generics.
Since the latter solution is preferred, but also much more invasive I'll spin those changes out to another cleanup issue.