2
0
Эх сурвалжийг харах

refactor: move src types folder

Evan You 3 жил өмнө
parent
commit
d6bdff8903
99 өөрчлөгдсөн 130 нэмэгдсэн , 131 устгасан
  1. 3 3
      .github/CONTRIBUTING.md
  2. 2 1
      api-extractor.tsconfig.json
  3. 1 1
      packages/server-renderer/src/create-basic-renderer.ts
  4. 1 1
      packages/server-renderer/src/create-renderer.ts
  5. 1 1
      packages/server-renderer/src/optimizing-compiler/codegen.ts
  6. 1 1
      packages/server-renderer/src/optimizing-compiler/index.ts
  7. 1 1
      packages/server-renderer/src/optimizing-compiler/modules.ts
  8. 1 1
      packages/server-renderer/src/optimizing-compiler/optimizer.ts
  9. 1 1
      packages/server-renderer/src/optimizing-compiler/runtime-helpers.ts
  10. 1 1
      packages/server-renderer/src/render-context.ts
  11. 2 2
      packages/server-renderer/src/render.ts
  12. 2 2
      packages/server-renderer/tsconfig.json
  13. 1 1
      src/compiler/codegen/events.ts
  14. 1 1
      src/compiler/codegen/index.ts
  15. 1 5
      src/compiler/create-compiler.ts
  16. 1 1
      src/compiler/directives/bind.ts
  17. 1 1
      src/compiler/directives/model.ts
  18. 1 1
      src/compiler/directives/on.ts
  19. 1 1
      src/compiler/error-detector.ts
  20. 1 1
      src/compiler/helpers.ts
  21. 1 1
      src/compiler/index.ts
  22. 1 1
      src/compiler/optimizer.ts
  23. 1 1
      src/compiler/parser/index.ts
  24. 2 2
      src/compiler/to-function.ts
  25. 2 2
      src/core/components/keep-alive.ts
  26. 1 1
      src/core/config.ts
  27. 1 1
      src/core/global-api/assets.ts
  28. 2 2
      src/core/global-api/extend.ts
  29. 1 1
      src/core/global-api/index.ts
  30. 1 1
      src/core/global-api/mixin.ts
  31. 1 1
      src/core/global-api/use.ts
  32. 1 1
      src/core/instance/events.ts
  33. 1 1
      src/core/instance/index.ts
  34. 2 2
      src/core/instance/init.ts
  35. 1 1
      src/core/instance/inject.ts
  36. 2 2
      src/core/instance/lifecycle.ts
  37. 1 1
      src/core/instance/render-helpers/bind-object-listeners.ts
  38. 1 1
      src/core/instance/render-helpers/bind-object-props.ts
  39. 1 1
      src/core/instance/render-helpers/resolve-scoped-slots.ts
  40. 1 1
      src/core/instance/render-helpers/resolve-slots.ts
  41. 1 1
      src/core/instance/render.ts
  42. 1 1
      src/core/instance/state.ts
  43. 1 1
      src/core/observer/scheduler.ts
  44. 1 1
      src/core/observer/watcher.ts
  45. 1 1
      src/core/util/debug.ts
  46. 2 2
      src/core/util/options.ts
  47. 1 1
      src/core/util/props.ts
  48. 3 6
      src/core/vdom/create-component.ts
  49. 2 2
      src/core/vdom/create-element.ts
  50. 2 2
      src/core/vdom/create-functional-component.ts
  51. 2 2
      src/core/vdom/helpers/extract-props.ts
  52. 1 1
      src/core/vdom/helpers/normalize-scoped-slots.ts
  53. 2 2
      src/core/vdom/helpers/resolve-async-component.ts
  54. 1 1
      src/core/vdom/helpers/update-listeners.ts
  55. 2 2
      src/core/vdom/modules/directives.ts
  56. 8 4
      src/core/vdom/modules/template-ref.ts
  57. 3 3
      src/core/vdom/vnode.ts
  58. 1 1
      src/platforms/web/compiler/directives/html.ts
  59. 1 1
      src/platforms/web/compiler/directives/model.ts
  60. 1 1
      src/platforms/web/compiler/directives/text.ts
  61. 1 1
      src/platforms/web/compiler/modules/class.ts
  62. 1 1
      src/platforms/web/compiler/modules/model.ts
  63. 1 1
      src/platforms/web/compiler/modules/style.ts
  64. 1 1
      src/platforms/web/compiler/options.ts
  65. 2 2
      src/platforms/web/runtime-with-compiler.ts
  66. 1 1
      src/platforms/web/runtime/components/transition-group.ts
  67. 1 1
      src/platforms/web/runtime/components/transition.ts
  68. 1 1
      src/platforms/web/runtime/directives/show.ts
  69. 1 1
      src/platforms/web/runtime/index.ts
  70. 1 1
      src/platforms/web/runtime/modules/attrs.ts
  71. 1 1
      src/platforms/web/runtime/modules/class.ts
  72. 1 1
      src/platforms/web/runtime/modules/dom-props.ts
  73. 1 1
      src/platforms/web/runtime/modules/events.ts
  74. 1 1
      src/platforms/web/runtime/modules/style.ts
  75. 1 1
      src/platforms/web/runtime/modules/transition.ts
  76. 1 1
      src/platforms/web/server/directives/model.ts
  77. 1 1
      src/platforms/web/server/directives/show.ts
  78. 1 1
      src/platforms/web/server/modules/attrs.ts
  79. 1 1
      src/platforms/web/server/modules/class.ts
  80. 1 1
      src/platforms/web/server/modules/dom-props.ts
  81. 1 1
      src/platforms/web/server/modules/style.ts
  82. 1 1
      src/platforms/web/util/class.ts
  83. 1 1
      src/platforms/web/util/style.ts
  84. 1 1
      src/sfc/parser.ts
  85. 0 0
      src/types/compiler.ts
  86. 2 2
      src/types/component.ts
  87. 1 1
      src/types/global-api.ts
  88. 0 0
      src/types/modules.d.ts
  89. 2 2
      src/types/options.ts
  90. 1 1
      src/types/ssr.ts
  91. 0 0
      src/types/utils.ts
  92. 2 2
      src/types/vnode.ts
  93. 1 1
      src/v3/apiLifecycle.ts
  94. 2 2
      src/v3/apiSetup.ts
  95. 1 1
      src/v3/currentInstance.ts
  96. 1 1
      src/v3/reactivity/ref.ts
  97. 2 2
      test/tsconfig.json
  98. 1 1
      test/unit/features/v3/apiWatch.spec.ts
  99. 2 1
      tsconfig.json

+ 3 - 3
.github/CONTRIBUTING.md

@@ -83,12 +83,10 @@ The default test script will do the following: lint with ESLint -> type check wi
 
   See [dist/README.md](https://github.com/vuejs/vue/blob/dev/dist/README.md) for more details on dist files.
 
-- **`types`**: contains public types published to npm. These were hand-authored before we moved the codebase from Flow to TypeScript. To ensure backwards compatibility, we keep using these manually authored types.
+- **`types`**: contains public types published to npm (note the types shipped here could be different from `src/types`). These were hand-authored before we moved the codebase from Flow to TypeScript. To ensure backwards compatibility, we keep using these manually authored types.
 
   Types for new features added in 2.7 (Composition API) are auto-generated from source code as `types/v3-generated.d.ts` and re-exported from `types/index.d.ts`.
 
-- **`typescript`**: contains type declarations added when we ported the codebase from Flow to TypeScript. These types should be considered internal - they care less about type inference for end-user scenarios and prioritize working with internal source code.
-
 - **`packages`**:
 
   - `vue-server-renderer` and `vue-template-compiler` are distributed as separate NPM packages. They are automatically generated from the source code and always have the same version with the main `vue` package.
@@ -129,6 +127,8 @@ The default test script will do the following: lint with ESLint -> type check wi
 
   - **`shared`**: contains utilities shared across the entire codebase.
 
+  - **`types`**: contains type declarations added when we ported the codebase from Flow to TypeScript. These types should be considered internal - they care less about type inference for end-user scenarios and prioritize working with internal source code.
+
 ## Financial Contribution
 
 As a pure community-driven project without major corporate backing, we also welcome financial contributions via GitHub Sponsors and OpenCollective. Please consult the [Sponsor Page](https://vuejs.org/sponsor/) for more details.

+ 2 - 1
api-extractor.tsconfig.json

@@ -28,8 +28,9 @@
       "web/*": ["src/platforms/web/*"],
       "v3": ["src/v3/index"],
       "v3/*": ["src/v3/*"],
+      "types/*": ["src/types/*"],
       "vue": ["src/platforms/web/entry-runtime-with-compiler"]
     }
   },
-  "include": ["src", "typescript"]
+  "include": ["src"]
 }

+ 1 - 1
packages/server-renderer/src/create-basic-renderer.ts

@@ -1,7 +1,7 @@
 import { createWriteFunction } from './write'
 import { createRenderFunction } from './render'
 import type { RenderOptions } from './create-renderer'
-import type { Component } from 'typescript/component'
+import type { Component } from 'types/component'
 
 export function createBasicRenderer({
   modules = [],

+ 1 - 1
packages/server-renderer/src/create-renderer.ts

@@ -4,7 +4,7 @@ import { createRenderFunction } from './render'
 import { createPromiseCallback } from './util'
 import TemplateRenderer from './template-renderer/index'
 import type { ClientManifest } from './template-renderer/index'
-import type { Component } from 'typescript/component'
+import type { Component } from 'types/component'
 import VNode from 'core/vdom/vnode'
 import { Readable } from 'stream'
 

+ 1 - 1
packages/server-renderer/src/optimizing-compiler/codegen.ts

@@ -23,7 +23,7 @@ import {
 import { escape } from 'web/server/util'
 import { optimizability } from './optimizer'
 import type { CodegenResult } from 'compiler/codegen/index'
-import { ASTElement, ASTNode, CompilerOptions } from 'typescript/compiler'
+import { ASTElement, ASTNode, CompilerOptions } from 'types/compiler'
 
 export type StringSegment = {
   type: number

+ 1 - 1
packages/server-renderer/src/optimizing-compiler/index.ts

@@ -2,7 +2,7 @@ import { parse } from 'compiler/parser/index'
 import { generate } from './codegen'
 import { optimize } from './optimizer'
 import { createCompilerCreator } from 'compiler/create-compiler'
-import { CompiledResult, CompilerOptions } from 'typescript/compiler'
+import { CompiledResult, CompilerOptions } from 'types/compiler'
 
 export const createCompiler = createCompilerCreator(function baseCompile(
   template: string,

+ 1 - 1
packages/server-renderer/src/optimizing-compiler/modules.ts

@@ -10,7 +10,7 @@ import { isBooleanAttr, isEnumeratedAttr } from 'web/util/attrs'
 
 import type { StringSegment } from './codegen'
 import type { CodegenState } from 'compiler/codegen/index'
-import { ASTAttr, ASTElement } from 'typescript/compiler'
+import { ASTAttr, ASTElement } from 'types/compiler'
 
 const plainStringRE = /^"(?:[^"\\]|\\.)*"$|^'(?:[^'\\]|\\.)*'$/
 

+ 1 - 1
packages/server-renderer/src/optimizing-compiler/optimizer.ts

@@ -9,7 +9,7 @@
  */
 
 import { no, makeMap, isBuiltInTag } from 'shared/util'
-import { ASTElement, ASTNode, CompilerOptions } from 'typescript/compiler'
+import { ASTElement, ASTNode, CompilerOptions } from 'types/compiler'
 
 // optimizability constants
 export const optimizability = {

+ 1 - 1
packages/server-renderer/src/optimizing-compiler/runtime-helpers.ts

@@ -11,7 +11,7 @@ import {
 } from 'core/vdom/helpers/normalize-children'
 
 import { propsToAttrMap, isRenderableAttr } from 'web/server/util'
-import type { Component } from 'typescript/component'
+import type { Component } from 'types/component'
 
 const ssrHelpers = {
   _ssrEscape: escape,

+ 1 - 1
packages/server-renderer/src/render-context.ts

@@ -1,6 +1,6 @@
 import VNode from 'core/vdom/vnode'
 import { isUndef } from 'shared/util'
-import { Component } from 'typescript/component'
+import { Component } from 'types/component'
 
 type RenderState =
   | {

+ 2 - 2
packages/server-renderer/src/render.ts

@@ -13,8 +13,8 @@ import {
   createComponentInstanceForVnode
 } from 'core/vdom/create-component'
 import VNode from 'core/vdom/vnode'
-import type { VNodeDirective } from 'typescript/vnode'
-import type { Component } from 'typescript/component'
+import type { VNodeDirective } from 'types/vnode'
+import type { Component } from 'types/component'
 
 let warned = Object.create(null)
 const warnOnce = msg => {

+ 2 - 2
packages/server-renderer/tsconfig.json

@@ -29,9 +29,9 @@
       "web/*": ["../../src/platforms/web/*"],
       "v3": ["../../src/v3/index"],
       "v3/*": ["../../src/v3/*"],
-      "typescript/*": ["../../typescript/*"],
+      "types/*": ["../../src/types/*"],
       "vue": ["../../src/platforms/web/entry-runtime-with-compiler"]
     }
   },
-  "include": ["../../src", "../../typescript", "../../test/test-env.d.ts", "."]
+  "include": ["../../src", "../../test/test-env.d.ts", "."]
 }

+ 1 - 1
src/compiler/codegen/events.ts

@@ -1,4 +1,4 @@
-import { ASTElementHandler, ASTElementHandlers } from 'typescript/compiler'
+import { ASTElementHandler, ASTElementHandlers } from 'types/compiler'
 
 const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/
 const fnInvokeRE = /\([^)]*?\);*$/

+ 1 - 1
src/compiler/codegen/index.ts

@@ -12,7 +12,7 @@ import {
   ASTNode,
   ASTText,
   CompilerOptions
-} from 'typescript/compiler'
+} from 'types/compiler'
 
 type TransformFunction = (el: ASTElement, code: string) => string
 type DataGenFunction = (el: ASTElement) => string

+ 1 - 5
src/compiler/create-compiler.ts

@@ -1,9 +1,5 @@
 import { extend } from 'shared/util'
-import {
-  CompilerOptions,
-  CompiledResult,
-  WarningMessage
-} from 'typescript/compiler'
+import { CompilerOptions, CompiledResult, WarningMessage } from 'types/compiler'
 import { detectErrors } from './error-detector'
 import { createCompileToFunctionFn } from './to-function'
 

+ 1 - 1
src/compiler/directives/bind.ts

@@ -1,4 +1,4 @@
-import { ASTDirective, ASTElement } from 'typescript/compiler'
+import { ASTDirective, ASTElement } from 'types/compiler'
 
 export default function bind(el: ASTElement, dir: ASTDirective) {
   el.wrapData = (code: string) => {

+ 1 - 1
src/compiler/directives/model.ts

@@ -1,4 +1,4 @@
-import { ASTElement, ASTModifiers } from 'typescript/compiler'
+import { ASTElement, ASTModifiers } from 'types/compiler'
 
 /**
  * Cross-platform code generation for component v-model

+ 1 - 1
src/compiler/directives/on.ts

@@ -1,5 +1,5 @@
 import { warn } from 'core/util/index'
-import { ASTDirective, ASTElement } from 'typescript/compiler'
+import { ASTDirective, ASTElement } from 'types/compiler'
 
 export default function on(el: ASTElement, dir: ASTDirective) {
   if (__DEV__ && dir.modifiers) {

+ 1 - 1
src/compiler/error-detector.ts

@@ -1,4 +1,4 @@
-import { ASTElement, ASTNode } from 'typescript/compiler'
+import { ASTElement, ASTNode } from 'types/compiler'
 import { dirRE, onRE } from './parser/index'
 
 type Range = { start?: number; end?: number }

+ 1 - 1
src/compiler/helpers.ts

@@ -1,5 +1,5 @@
 import { emptyObject } from 'shared/util'
-import { ASTElement, ASTModifiers } from 'typescript/compiler'
+import { ASTElement, ASTModifiers } from 'types/compiler'
 import { parseFilters } from './parser/filter-parser'
 
 type Range = { start?: number; end?: number }

+ 1 - 1
src/compiler/index.ts

@@ -2,7 +2,7 @@ import { parse } from './parser/index'
 import { optimize } from './optimizer'
 import { generate } from './codegen/index'
 import { createCompilerCreator } from './create-compiler'
-import { CompilerOptions, CompiledResult } from 'typescript/compiler'
+import { CompilerOptions, CompiledResult } from 'types/compiler'
 
 // `createCompilerCreator` allows creating compilers that use alternative
 // parser/optimizer/codegen, e.g the SSR optimizing compiler.

+ 1 - 1
src/compiler/optimizer.ts

@@ -1,5 +1,5 @@
 import { makeMap, isBuiltInTag, cached, no } from 'shared/util'
-import { ASTElement, CompilerOptions, ASTNode } from 'typescript/compiler'
+import { ASTElement, CompilerOptions, ASTNode } from 'types/compiler'
 
 let isStaticKey
 let isPlatformReservedTag

+ 1 - 1
src/compiler/parser/index.ts

@@ -26,7 +26,7 @@ import {
   ASTNode,
   ASTText,
   CompilerOptions
-} from 'typescript/compiler'
+} from 'types/compiler'
 
 export const onRE = /^@|^v-on:/
 export const dirRE = process.env.VBIND_PROP_SHORTHAND

+ 2 - 2
src/compiler/to-function.ts

@@ -1,8 +1,8 @@
 import { noop, extend } from 'shared/util'
 import { warn as baseWarn, tip } from 'core/util/debug'
 import { generateCodeFrame } from './codeframe'
-import type { Component } from 'typescript/component'
-import { CompilerOptions } from 'typescript/compiler'
+import type { Component } from 'types/component'
+import { CompilerOptions } from 'types/compiler'
 
 type CompiledFunctionResult = {
   render: Function

+ 2 - 2
src/core/components/keep-alive.ts

@@ -1,8 +1,8 @@
 import { isRegExp, isArray, remove } from 'shared/util'
 import { getFirstComponentChild } from 'core/vdom/helpers/index'
 import type VNode from 'core/vdom/vnode'
-import type { VNodeComponentOptions } from 'typescript/vnode'
-import type { Component } from 'typescript/component'
+import type { VNodeComponentOptions } from 'types/vnode'
+import type { Component } from 'types/component'
 
 type CacheEntry = {
   name?: string

+ 1 - 1
src/core/config.ts

@@ -1,7 +1,7 @@
 import { no, noop, identity } from 'shared/util'
 
 import { LIFECYCLE_HOOKS } from 'shared/constants'
-import type { Component } from 'typescript/component'
+import type { Component } from 'types/component'
 
 /**
  * @internal

+ 1 - 1
src/core/global-api/assets.ts

@@ -1,5 +1,5 @@
 import { ASSET_TYPES } from 'shared/constants'
-import type { GlobalAPI } from 'typescript/global-api'
+import type { GlobalAPI } from 'types/global-api'
 import { isFunction, isPlainObject, validateComponentName } from '../util/index'
 
 export function initAssetRegisters(Vue: GlobalAPI) {

+ 2 - 2
src/core/global-api/extend.ts

@@ -1,6 +1,6 @@
 import { ASSET_TYPES } from 'shared/constants'
-import type { Component } from 'typescript/component'
-import type { GlobalAPI } from 'typescript/global-api'
+import type { Component } from 'types/component'
+import type { GlobalAPI } from 'types/global-api'
 import { defineComputed, proxy } from '../instance/state'
 import { extend, mergeOptions, validateComponentName } from '../util/index'
 

+ 1 - 1
src/core/global-api/index.ts

@@ -15,7 +15,7 @@ import {
   mergeOptions,
   defineReactive
 } from '../util/index'
-import type { GlobalAPI } from 'typescript/global-api'
+import type { GlobalAPI } from 'types/global-api'
 
 export function initGlobalAPI(Vue: GlobalAPI) {
   // config

+ 1 - 1
src/core/global-api/mixin.ts

@@ -1,4 +1,4 @@
-import type { GlobalAPI } from 'typescript/global-api'
+import type { GlobalAPI } from 'types/global-api'
 import { mergeOptions } from '../util/index'
 
 export function initMixin(Vue: GlobalAPI) {

+ 1 - 1
src/core/global-api/use.ts

@@ -1,4 +1,4 @@
-import type { GlobalAPI } from 'typescript/global-api'
+import type { GlobalAPI } from 'types/global-api'
 import { toArray, isFunction } from '../util/index'
 
 export function initUse(Vue: GlobalAPI) {

+ 1 - 1
src/core/instance/events.ts

@@ -1,4 +1,4 @@
-import type { Component } from 'typescript/component'
+import type { Component } from 'types/component'
 import {
   tip,
   toArray,

+ 1 - 1
src/core/instance/index.ts

@@ -4,7 +4,7 @@ import { renderMixin } from './render'
 import { eventsMixin } from './events'
 import { lifecycleMixin } from './lifecycle'
 import { warn } from '../util/index'
-import type { GlobalAPI } from 'typescript/global-api'
+import type { GlobalAPI } from 'types/global-api'
 
 function Vue(options) {
   if (__DEV__ && !(this instanceof Vue)) {

+ 2 - 2
src/core/instance/init.ts

@@ -7,8 +7,8 @@ import { mark, measure } from '../util/perf'
 import { initLifecycle, callHook } from './lifecycle'
 import { initProvide, initInjections } from './inject'
 import { extend, mergeOptions, formatComponentName } from '../util/index'
-import type { Component } from 'typescript/component'
-import type { InternalComponentOptions } from 'typescript/options'
+import type { Component } from 'types/component'
+import type { InternalComponentOptions } from 'types/options'
 import { EffectScope } from 'v3/reactivity/effectScope'
 
 let uid = 0

+ 1 - 1
src/core/instance/inject.ts

@@ -1,6 +1,6 @@
 import { warn, hasSymbol, isFunction } from '../util/index'
 import { defineReactive, toggleObserving } from '../observer/index'
-import type { Component } from 'typescript/component'
+import type { Component } from 'types/component'
 import { provide } from 'v3/apiInject'
 import { setCurrentInstance } from '../../v3/currentInstance'
 

+ 2 - 2
src/core/instance/lifecycle.ts

@@ -6,8 +6,8 @@ import { updateComponentListeners } from './events'
 import { resolveSlots } from './render-helpers/resolve-slots'
 import { toggleObserving } from '../observer/index'
 import { pushTarget, popTarget } from '../observer/dep'
-import type { Component } from '../../../typescript/component'
-import type { MountedComponentVNode } from '../../../typescript/vnode'
+import type { Component } from 'types/component'
+import type { MountedComponentVNode } from 'types/vnode'
 
 import {
   warn,

+ 1 - 1
src/core/instance/render-helpers/bind-object-listeners.ts

@@ -1,5 +1,5 @@
 import { warn, extend, isPlainObject } from 'core/util/index'
-import type { VNodeData } from 'typescript/vnode'
+import type { VNodeData } from 'types/vnode'
 
 export function bindObjectListeners(data: any, value: any): VNodeData {
   if (value) {

+ 1 - 1
src/core/instance/render-helpers/bind-object-props.ts

@@ -9,7 +9,7 @@ import {
   hyphenate,
   isArray
 } from 'core/util/index'
-import type { VNodeData } from 'typescript/vnode'
+import type { VNodeData } from 'types/vnode'
 
 /**
  * Runtime helper for merging v-bind="object" into a VNode's data.

+ 1 - 1
src/core/instance/render-helpers/resolve-scoped-slots.ts

@@ -1,4 +1,4 @@
-import type { ScopedSlotsData } from 'typescript/vnode'
+import type { ScopedSlotsData } from 'types/vnode'
 import { isArray } from 'core/util'
 
 export function resolveScopedSlots(

+ 1 - 1
src/core/instance/render-helpers/resolve-slots.ts

@@ -1,5 +1,5 @@
 import type VNode from 'core/vdom/vnode'
-import type { Component } from 'typescript/component'
+import type { Component } from 'types/component'
 
 /**
  * Runtime helper for resolving raw children VNodes into a slot object.

+ 1 - 1
src/core/instance/render.ts

@@ -14,7 +14,7 @@ import { normalizeScopedSlots } from '../vdom/helpers/normalize-scoped-slots'
 import VNode, { createEmptyVNode } from '../vdom/vnode'
 
 import { isUpdatingChildComponent } from './lifecycle'
-import type { Component } from 'typescript/component'
+import type { Component } from 'types/component'
 import { setCurrentInstance } from 'v3/currentInstance'
 import { syncSetupSlots } from 'v3/apiSetup'
 

+ 1 - 1
src/core/instance/state.ts

@@ -29,7 +29,7 @@ import {
   invokeWithErrorHandling,
   isFunction
 } from '../util/index'
-import type { Component } from 'typescript/component'
+import type { Component } from 'types/component'
 import { TrackOpTypes } from '../../v3'
 
 const sharedPropertyDefinition = {

+ 1 - 1
src/core/observer/scheduler.ts

@@ -4,7 +4,7 @@ import Dep from './dep'
 import { callHook, activateChildComponent } from '../instance/lifecycle'
 
 import { warn, nextTick, devtools, inBrowser, isIE } from '../util/index'
-import type { Component } from 'typescript/component'
+import type { Component } from 'types/component'
 
 export const MAX_UPDATE_COUNT = 100
 

+ 1 - 1
src/core/observer/watcher.ts

@@ -16,7 +16,7 @@ import Dep, { pushTarget, popTarget, DepTarget } from './dep'
 import { DebuggerEvent, DebuggerOptions } from 'v3/debug'
 
 import type { SimpleSet } from '../util/index'
-import type { Component } from 'typescript/component'
+import type { Component } from 'types/component'
 import { activeEffectScope, recordEffectScope } from 'v3/reactivity/effectScope'
 
 let uid = 0

+ 1 - 1
src/core/util/debug.ts

@@ -1,6 +1,6 @@
 import config from '../config'
 import { noop, isArray, isFunction } from 'shared/util'
-import type { Component } from 'typescript/component'
+import type { Component } from 'types/component'
 import { currentInstance } from 'v3/currentInstance'
 
 export let warn = noop

+ 2 - 2
src/core/util/options.ts

@@ -16,8 +16,8 @@ import {
   isBuiltInTag,
   isPlainObject
 } from 'shared/util'
-import type { Component } from 'typescript/component'
-import type { ComponentOptions } from 'typescript/options'
+import type { Component } from 'types/component'
+import type { ComponentOptions } from 'types/options'
 
 /**
  * Option overwriting strategies are functions that handle

+ 1 - 1
src/core/util/props.ts

@@ -10,7 +10,7 @@ import {
   capitalize,
   isPlainObject
 } from 'shared/util'
-import type { Component } from 'typescript/component'
+import type { Component } from 'types/component'
 
 type PropOptions = {
   type: Function | Array<Function> | null

+ 3 - 6
src/core/vdom/create-component.ts

@@ -24,12 +24,9 @@ import type {
   MountedComponentVNode,
   VNodeData,
   VNodeWithData
-} from 'typescript/vnode'
-import type { Component } from 'typescript/component'
-import type {
-  ComponentOptions,
-  InternalComponentOptions
-} from 'typescript/options'
+} from 'types/vnode'
+import type { Component } from 'types/component'
+import type { ComponentOptions, InternalComponentOptions } from 'types/options'
 
 // inline hooks to be invoked on component VNodes during patch
 const componentVNodeHooks = {

+ 2 - 2
src/core/vdom/create-element.ts

@@ -16,8 +16,8 @@ import {
 } from '../util/index'
 
 import { normalizeChildren, simpleNormalizeChildren } from './helpers/index'
-import type { Component } from 'typescript/component'
-import type { VNodeData } from 'typescript/vnode'
+import type { Component } from 'types/component'
+import type { VNodeData } from 'types/vnode'
 
 const SIMPLE_NORMALIZE = 1
 const ALWAYS_NORMALIZE = 2

+ 2 - 2
src/core/vdom/create-functional-component.ts

@@ -15,8 +15,8 @@ import {
   emptyObject,
   validateProp
 } from '../util/index'
-import type { Component } from 'typescript/component'
-import type { VNodeData } from 'typescript/vnode'
+import type { Component } from 'types/component'
+import type { VNodeData } from 'types/vnode'
 
 export function FunctionalRenderContext(
   data: VNodeData,

+ 2 - 2
src/core/vdom/helpers/extract-props.ts

@@ -6,8 +6,8 @@ import {
   hyphenate,
   formatComponentName
 } from 'core/util/index'
-import type { Component } from 'typescript/component'
-import type { VNodeData } from 'typescript/vnode'
+import type { Component } from 'types/component'
+import type { VNodeData } from 'types/vnode'
 
 export function extractPropsFromVNodeData(
   data: VNodeData,

+ 1 - 1
src/core/vdom/helpers/normalize-scoped-slots.ts

@@ -3,7 +3,7 @@ import { normalizeChildren } from 'core/vdom/helpers/normalize-children'
 import { emptyObject, isArray } from 'shared/util'
 import { isAsyncPlaceholder } from './is-async-placeholder'
 import type VNode from '../vnode'
-import { Component } from 'typescript/component'
+import { Component } from 'types/component'
 import { currentInstance, setCurrentInstance } from 'v3/currentInstance'
 
 export function normalizeScopedSlots(

+ 2 - 2
src/core/vdom/helpers/resolve-async-component.ts

@@ -12,8 +12,8 @@ import {
 
 import VNode, { createEmptyVNode } from 'core/vdom/vnode'
 import { currentRenderingInstance } from 'core/instance/render'
-import type { VNodeData } from 'typescript/vnode'
-import type { Component } from 'typescript/component'
+import type { VNodeData } from 'types/vnode'
+import type { Component } from 'types/component'
 
 function ensureCtor(comp: any, base) {
   if (comp.__esModule || (hasSymbol && comp[Symbol.toStringTag] === 'Module')) {

+ 1 - 1
src/core/vdom/helpers/update-listeners.ts

@@ -1,6 +1,6 @@
 import { warn, invokeWithErrorHandling } from 'core/util/index'
 import { cached, isUndef, isTrue, isArray } from 'shared/util'
-import type { Component } from 'typescript/component'
+import type { Component } from 'types/component'
 
 const normalizeEvent = cached(
   (

+ 2 - 2
src/core/vdom/modules/directives.ts

@@ -1,8 +1,8 @@
 import { emptyNode } from 'core/vdom/patch'
 import { resolveAsset, handleError } from 'core/util/index'
 import { mergeVNodeHook } from 'core/vdom/helpers/index'
-import type { VNodeDirective, VNodeWithData } from 'typescript/vnode'
-import type { Component } from 'typescript/component'
+import type { VNodeDirective, VNodeWithData } from 'types/vnode'
+import type { Component } from 'types/component'
 
 export default {
   create: updateDirectives,

+ 8 - 4
src/core/vdom/modules/template-ref.ts

@@ -7,8 +7,8 @@ import {
   invokeWithErrorHandling,
   warn
 } from 'core/util'
-import type { VNodeWithData } from 'typescript/vnode'
-import { Component } from 'typescript/component'
+import type { VNodeWithData } from 'types/vnode'
+import { Component } from 'types/component'
 import { isRef } from 'v3'
 
 export default {
@@ -81,8 +81,12 @@ export function registerRef(vnode: VNodeWithData, isRemoval?: boolean) {
   }
 }
 
-function setSetupRef({ _setupState }: Component, key: string, val: any) {
-  if (_setupState && hasOwn(_setupState, key)) {
+function setSetupRef(
+  { _setupState }: Component,
+  key: string | number,
+  val: any
+) {
+  if (_setupState && hasOwn(_setupState, key as string)) {
     if (isRef(_setupState[key])) {
       _setupState[key].value = val
     } else {

+ 3 - 3
src/core/vdom/vnode.ts

@@ -1,6 +1,6 @@
-import type { Component } from 'typescript/component'
-import type { ComponentOptions } from 'typescript/options'
-import type { VNodeComponentOptions, VNodeData } from 'typescript/vnode'
+import type { Component } from 'types/component'
+import type { ComponentOptions } from 'types/options'
+import type { VNodeComponentOptions, VNodeData } from 'types/vnode'
 
 /**
  * @internal

+ 1 - 1
src/platforms/web/compiler/directives/html.ts

@@ -1,5 +1,5 @@
 import { addProp } from 'compiler/helpers'
-import { ASTDirective, ASTElement } from 'typescript/compiler'
+import { ASTDirective, ASTElement } from 'types/compiler'
 
 export default function html(el: ASTElement, dir: ASTDirective) {
   if (dir.value) {

+ 1 - 1
src/platforms/web/compiler/directives/model.ts

@@ -1,7 +1,7 @@
 import config from 'core/config'
 import { addHandler, addProp, getBindingAttr } from 'compiler/helpers'
 import { genComponentModel, genAssignmentCode } from 'compiler/directives/model'
-import { ASTDirective, ASTElement, ASTModifiers } from 'typescript/compiler'
+import { ASTDirective, ASTElement, ASTModifiers } from 'types/compiler'
 
 let warn
 

+ 1 - 1
src/platforms/web/compiler/directives/text.ts

@@ -1,5 +1,5 @@
 import { addProp } from 'compiler/helpers'
-import { ASTDirective, ASTElement } from 'typescript/compiler'
+import { ASTDirective, ASTElement } from 'types/compiler'
 
 export default function text(el: ASTElement, dir: ASTDirective) {
   if (dir.value) {

+ 1 - 1
src/platforms/web/compiler/modules/class.ts

@@ -1,6 +1,6 @@
 import { parseText } from 'compiler/parser/text-parser'
 import { getAndRemoveAttr, getBindingAttr, baseWarn } from 'compiler/helpers'
-import { ASTElement, CompilerOptions, ModuleOptions } from 'typescript/compiler'
+import { ASTElement, CompilerOptions, ModuleOptions } from 'types/compiler'
 
 function transformNode(el: ASTElement, options: CompilerOptions) {
   const warn = options.warn || baseWarn

+ 1 - 1
src/platforms/web/compiler/modules/model.ts

@@ -16,7 +16,7 @@ import {
   addIfCondition,
   createASTElement
 } from 'compiler/parser/index'
-import { ASTElement, CompilerOptions, ModuleOptions } from 'typescript/compiler'
+import { ASTElement, CompilerOptions, ModuleOptions } from 'types/compiler'
 
 function preTransformNode(el: ASTElement, options: CompilerOptions) {
   if (el.tag === 'input') {

+ 1 - 1
src/platforms/web/compiler/modules/style.ts

@@ -1,7 +1,7 @@
 import { parseText } from 'compiler/parser/text-parser'
 import { parseStyleText } from 'web/util/style'
 import { getAndRemoveAttr, getBindingAttr, baseWarn } from 'compiler/helpers'
-import { ASTElement, CompilerOptions, ModuleOptions } from 'typescript/compiler'
+import { ASTElement, CompilerOptions, ModuleOptions } from 'types/compiler'
 
 function transformNode(el: ASTElement, options: CompilerOptions) {
   const warn = options.warn || baseWarn

+ 1 - 1
src/platforms/web/compiler/options.ts

@@ -9,7 +9,7 @@ import modules from './modules/index'
 import directives from './directives/index'
 import { genStaticKeys } from 'shared/util'
 import { isUnaryTag, canBeLeftOpenTag } from './util'
-import { CompilerOptions } from 'typescript/compiler'
+import { CompilerOptions } from 'types/compiler'
 
 export const baseOptions: CompilerOptions = {
   expectHTML: true,

+ 2 - 2
src/platforms/web/runtime-with-compiler.ts

@@ -9,8 +9,8 @@ import {
   shouldDecodeNewlines,
   shouldDecodeNewlinesForHref
 } from './util/compat'
-import type { Component } from 'typescript/component'
-import type { GlobalAPI } from 'typescript/global-api'
+import type { Component } from 'types/component'
+import type { GlobalAPI } from 'types/global-api'
 
 const idToTemplate = cached(id => {
   const el = query(id)

+ 1 - 1
src/platforms/web/runtime/components/transition-group.ts

@@ -22,7 +22,7 @@ import {
   removeTransitionClass
 } from 'web/runtime/transition-util'
 import VNode from 'core/vdom/vnode'
-import { VNodeWithData } from 'typescript/vnode'
+import { VNodeWithData } from 'types/vnode'
 
 const props = extend(
   {

+ 1 - 1
src/platforms/web/runtime/components/transition.ts

@@ -9,7 +9,7 @@ import {
   getFirstComponentChild
 } from 'core/vdom/helpers/index'
 import VNode from 'core/vdom/vnode'
-import type { Component } from 'typescript/component'
+import type { Component } from 'types/component'
 
 export const transitionProps = {
   name: String,

+ 1 - 1
src/platforms/web/runtime/directives/show.ts

@@ -1,5 +1,5 @@
 import VNode from 'core/vdom/vnode'
-import type { VNodeDirective, VNodeWithData } from 'typescript/vnode'
+import type { VNodeDirective, VNodeWithData } from 'types/vnode'
 import { enter, leave } from 'web/runtime/modules/transition'
 
 // recursively search for possible transition defined inside the component root

+ 1 - 1
src/platforms/web/runtime/index.ts

@@ -16,7 +16,7 @@ import {
 import { patch } from './patch'
 import platformDirectives from './directives/index'
 import platformComponents from './components/index'
-import type { Component } from 'typescript/component'
+import type { Component } from 'types/component'
 
 // install platform specific utils
 Vue.config.mustUseProp = mustUseProp

+ 1 - 1
src/platforms/web/runtime/modules/attrs.ts

@@ -1,7 +1,7 @@
 import { isIE, isIE9, isEdge } from 'core/util/env'
 
 import { extend, isDef, isUndef, isTrue } from 'shared/util'
-import type { VNodeWithData } from 'typescript/vnode'
+import type { VNodeWithData } from 'types/vnode'
 
 import {
   isXlink,

+ 1 - 1
src/platforms/web/runtime/modules/class.ts

@@ -1,5 +1,5 @@
 import { isDef, isUndef } from 'shared/util'
-import type { VNodeData } from 'typescript/vnode'
+import type { VNodeData } from 'types/vnode'
 
 import { concat, stringifyClass, genClassForVnode } from 'web/util/index'
 

+ 1 - 1
src/platforms/web/runtime/modules/dom-props.ts

@@ -1,5 +1,5 @@
 import { isDef, isUndef, extend, toNumber, isTrue } from 'shared/util'
-import type { VNodeWithData } from 'typescript/vnode'
+import type { VNodeWithData } from 'types/vnode'
 import { isSVG } from 'web/util/index'
 
 let svgContainer

+ 1 - 1
src/platforms/web/runtime/modules/events.ts

@@ -7,7 +7,7 @@ import {
 } from 'web/compiler/directives/model'
 import { currentFlushTimestamp } from 'core/observer/scheduler'
 import { emptyNode } from 'core/vdom/patch'
-import type { VNodeWithData } from 'typescript/vnode'
+import type { VNodeWithData } from 'types/vnode'
 
 // normalize v-model event tokens that can only be determined at runtime.
 // it's important to place the event as the first in the array because

+ 1 - 1
src/platforms/web/runtime/modules/style.ts

@@ -7,7 +7,7 @@ import {
   isUndef,
   hyphenate
 } from 'shared/util'
-import type { VNodeWithData } from 'typescript/vnode'
+import type { VNodeWithData } from 'types/vnode'
 
 const cssVarRE = /^--/
 const importantRE = /\s*!important$/

+ 1 - 1
src/platforms/web/runtime/modules/transition.ts

@@ -19,7 +19,7 @@ import {
   removeTransitionClass
 } from 'web/runtime/transition-util'
 
-import type { VNodeWithData } from 'typescript/vnode'
+import type { VNodeWithData } from 'types/vnode'
 import VNode from 'core/vdom/vnode'
 
 export function enter(vnode: VNodeWithData, toggleDisplay?: () => void) {

+ 1 - 1
src/platforms/web/server/directives/model.ts

@@ -1,5 +1,5 @@
 import { looseEqual, looseIndexOf } from 'shared/util'
-import type { VNodeDirective, VNodeWithData } from 'typescript/vnode'
+import type { VNodeDirective, VNodeWithData } from 'types/vnode'
 
 // this is only applied for <select v-model> because it is the only edge case
 // that must be done at runtime instead of compile time.

+ 1 - 1
src/platforms/web/server/directives/show.ts

@@ -1,4 +1,4 @@
-import type { VNodeDirective, VNodeWithData } from 'typescript/vnode'
+import type { VNodeDirective, VNodeWithData } from 'types/vnode'
 
 export default function show(node: VNodeWithData, dir: VNodeDirective) {
   if (!dir.value) {

+ 1 - 1
src/platforms/web/server/modules/attrs.ts

@@ -10,7 +10,7 @@ import {
 } from 'web/util/attrs'
 
 import { isSSRUnsafeAttr } from 'web/server/util'
-import type { VNodeWithData } from 'typescript/vnode'
+import type { VNodeWithData } from 'types/vnode'
 
 export default function renderAttrs(node: VNodeWithData): string {
   let attrs = node.data.attrs

+ 1 - 1
src/platforms/web/server/modules/class.ts

@@ -1,6 +1,6 @@
 import { escape } from '../util'
 import { genClassForVnode } from 'web/util/index'
-import type { VNodeWithData } from 'typescript/vnode'
+import type { VNodeWithData } from 'types/vnode'
 
 export default function renderClass(node: VNodeWithData): string | undefined {
   const classList = genClassForVnode(node)

+ 1 - 1
src/platforms/web/server/modules/dom-props.ts

@@ -2,7 +2,7 @@ import VNode from 'core/vdom/vnode'
 import { renderAttr } from './attrs'
 import { isDef, isUndef, extend, toString } from 'shared/util'
 import { propsToAttrMap, isRenderableAttr } from '../util'
-import type { VNodeWithData } from 'typescript/vnode'
+import type { VNodeWithData } from 'types/vnode'
 
 export default function renderDOMProps(node: VNodeWithData): string {
   let props = node.data.domProps

+ 1 - 1
src/platforms/web/server/modules/style.ts

@@ -1,7 +1,7 @@
 import { escape, noUnitNumericStyleProps } from '../util'
 import { hyphenate } from 'shared/util'
 import { getStyle } from 'web/util/style'
-import type { VNodeWithData } from 'typescript/vnode'
+import type { VNodeWithData } from 'types/vnode'
 
 export function genStyle(style: Object): string {
   let styleText = ''

+ 1 - 1
src/platforms/web/util/class.ts

@@ -1,6 +1,6 @@
 import VNode from 'core/vdom/vnode'
 import { isDef, isObject } from 'shared/util'
-import type { VNodeData, VNodeWithData } from 'typescript/vnode'
+import type { VNodeData, VNodeWithData } from 'types/vnode'
 
 export function genClassForVnode(vnode: VNodeWithData): string {
   let data = vnode.data

+ 1 - 1
src/platforms/web/util/style.ts

@@ -1,6 +1,6 @@
 import VNode from 'core/vdom/vnode'
 import { cached, extend, toObject } from 'shared/util'
-import type { VNodeData, VNodeWithData } from 'typescript/vnode'
+import type { VNodeData, VNodeWithData } from 'types/vnode'
 
 export const parseStyleText = cached(function (cssText) {
   const res = {}

+ 1 - 1
src/sfc/parser.ts

@@ -6,7 +6,7 @@ import {
   SFCBlock,
   SFCDescriptor,
   WarningMessage
-} from 'typescript/compiler'
+} from 'types/compiler'
 
 const splitRE = /\r?\n/g
 const replaceRE = /./g

+ 0 - 0
typescript/compiler.ts → src/types/compiler.ts


+ 2 - 2
typescript/component.ts → src/types/component.ts

@@ -1,5 +1,5 @@
-import type VNode from '../src/core/vdom/vnode'
-import type Watcher from '../src/core/observer/watcher'
+import type VNode from 'core/vdom/vnode'
+import type Watcher from 'core/observer/watcher'
 import { ComponentOptions, SetupContext } from './options'
 import { ScopedSlotsData, VNodeChildren, VNodeData } from './vnode'
 import { GlobalAPI } from './global-api'

+ 1 - 1
typescript/global-api.ts → src/types/global-api.ts

@@ -1,4 +1,4 @@
-import { Config } from '../src/core/config'
+import { Config } from 'core/config'
 import { Component } from './component'
 
 /**

+ 0 - 0
typescript/modules.d.ts → src/types/modules.d.ts


+ 2 - 2
typescript/options.ts → src/types/options.ts

@@ -1,5 +1,5 @@
-import VNode from '../src/core/vdom/vnode'
-import { DebuggerEvent } from '../src/v3'
+import VNode from 'core/vdom/vnode'
+import { DebuggerEvent } from 'v3'
 import { Component } from './component'
 
 export type InternalComponentOptions = {

+ 1 - 1
typescript/ssr.ts → src/types/ssr.ts

@@ -1,4 +1,4 @@
-import VNode from '../src/core/vdom/vnode'
+import VNode from 'core/vdom/vnode'
 import { Component } from './component'
 
 export type ComponentWithCacheContext = {

+ 0 - 0
typescript/utils.ts → src/types/utils.ts


+ 2 - 2
typescript/vnode.ts → src/types/vnode.ts

@@ -1,5 +1,5 @@
-import VNode from '../src/core/vdom/vnode'
-import { Ref } from '../src/v3'
+import VNode from 'core/vdom/vnode'
+import { Ref } from 'v3'
 import { Component } from './component'
 import { ASTModifiers } from './compiler'
 

+ 1 - 1
src/v3/apiLifecycle.ts

@@ -1,5 +1,5 @@
 import { DebuggerEvent } from './debug'
-import { Component } from 'typescript/component'
+import { Component } from 'types/component'
 import { mergeLifecycleHook, warn } from '../core/util'
 import { currentInstance } from './currentInstance'
 

+ 2 - 2
src/v3/apiSetup.ts

@@ -1,5 +1,5 @@
-import { Component } from 'typescript/component'
-import type { SetupContext } from 'typescript/options'
+import { Component } from 'types/component'
+import type { SetupContext } from 'types/options'
 import { def, invokeWithErrorHandling, isReserved, warn } from '../core/util'
 import VNode from '../core/vdom/vnode'
 import { bind, emptyObject, isFunction, isObject } from '../shared/util'

+ 1 - 1
src/v3/currentInstance.ts

@@ -1,4 +1,4 @@
-import { Component } from 'typescript/component'
+import { Component } from 'types/component'
 
 export let currentInstance: Component | null = null
 

+ 1 - 1
src/v3/reactivity/ref.ts

@@ -4,7 +4,7 @@ import {
   ReactiveFlags,
   type ShallowReactiveMarker
 } from './reactive'
-import type { IfAny } from 'typescript/utils'
+import type { IfAny } from 'types/utils'
 import Dep from 'core/observer/dep'
 import { warn, isArray, def } from 'core/util'
 import { TrackOpTypes, TriggerOpTypes } from './operations'

+ 2 - 2
test/tsconfig.json

@@ -29,9 +29,9 @@
       "web/*": ["../src/platforms/web/*"],
       "v3": ["../src/v3/index"],
       "v3/*": ["../src/v3/*"],
-      "typescript/*": ["../typescript/*"],
+      "types/*": ["../src/types/*"],
       "vue": ["../src/platforms/web/entry-runtime-with-compiler"]
     }
   },
-  "include": ["../src", "../typescript", "."]
+  "include": ["../src", "."]
 }

+ 1 - 1
test/unit/features/v3/apiWatch.spec.ts

@@ -19,7 +19,7 @@ import {
 } from 'v3'
 import { nextTick } from 'core/util'
 import { set } from 'core/observer'
-import { Component } from 'typescript/component'
+import { Component } from 'types/component'
 
 // reference: https://vue-composition-api-rfc.netlify.com/api.html#watch
 

+ 2 - 1
tsconfig.json

@@ -29,8 +29,9 @@
       "web/*": ["src/platforms/web/*"],
       "v3": ["src/v3/index"],
       "v3/*": ["src/v3/*"],
+      "types/*": ["src/types/*"],
       "vue": ["src/platforms/web/entry-runtime-with-compiler"]
     }
   },
-  "include": ["src", "typescript", "packages/server-renderer/server"],
+  "include": ["src", "packages/server-renderer/src"],
 }