---
title: "규칙 3.9: 텍스트 구조와 이름, TypeShade 셰이더 언어 설계 규칙과 그 근거, 출처, 검증 방식"
description: "TypeShade 언어 설계 규칙 3.9(텍스트 구조와 이름)입니다. A shader file may import what another shader file exports, by a relative specifier or…"
url: https://typeshade.dev/ko/reference/rules/3-9/
language: ko
---

# 규칙 3.9

3장, 텍스트 구조와 이름 테스트

A shader file may import what another shader file exports, by a relative specifier or, from a package, by the package’s name; the file a compile starts from and every shader file it imports, directly or through another, are one program, which emits one module, and each file keeps the scope TypeScript gives it. Every declaration a file can make at the top level can be exported and imported, by name (`import { a, b as c }`), as a type (`import type`), through a module namespace read one name at a time (`import * as ns`, then `ns.f`), and through a re-export (`export { a } from`, `export { a as b } from`, `export * from`); the module holds the entry’s declarations and what it re-exports and, of each imported file, what those reach, so an imported file’s own entry points are not in it. One requested-root exception is a pure alias (change 0126): exactly the `"use typeshade"` directive followed by one non-type-only `export * from` with no export clause or attributes. Comments, whitespace and statement terminators do not add statements; an extra empty statement, directive or declaration makes the root ordinary. Follow that root’s pure aliases through the existing resolver to the first non-alias target. Retain and validate the target’s declarations and other module statements as a direct root, including unused private declarations, entry points and directives with no declaration unit, plus their ordinary transitive dependencies. Preserve declaration order and binding names, groups and slots; existing package identities, version deduplication and private-name prefixes remain. Retention does not export private names or add an unused binding to an entry call’s arguments. Ordinary imports and re-exports do not promote a pure-looking dependency. An alias-only cycle has no terminal target and uses bounded ordinary linking, without a new refusal. The requested path remains the compilation and host-module identity, including generated headers, view destinations and default fusion origin; an explicit origin remains exact. Source spans and target errors remain on their authored files, import failures remain on their failed edges, and watch dependencies include the alias chain and the files read. A target’s existing direct-compilation refusal must not disappear through pruning. Authored defaults gain no support or forwarding. These guarantees do not imply byte-identical artifacts across paths or remove existing package-prefix differences. A relative specifier resolves against the importing file, with `.js` and `.mjs` read as `.ts` and `.ts` appended to any other path; any other names a package, `name` or `@scope/name` and an optional subpath, which is the first `node_modules/<name>/package.json` from the importing file’s directory up: with `exports`, the subpath is looked up in it as Node looks it up, with the conditions `typeshade`, `import` and `default` tried in that order, and without `exports`, a subpath names a file of the package by the relative rule; both by the one rule the language service resolves an import by. A program holds one copy of a package version: a file of a package is one file by the package’s name, its version and its path in the package, however many paths reach it. An import the compiler does not follow must be refused with [`TS8072`](https://typeshade.dev/ko/reference/errors/ts8072/), on the import: a path that names no file or one the compile cannot read, a file that does not begin with the directive ([Rule 3.1](https://typeshade.dev/ko/reference/rules/3-1/)), a package no `node_modules` holds, a subpath a package’s `exports` does not name or maps to `null`, a package’s name alone when it has no `exports`, a `#` specifier of a package’s import map, a specifier that is neither relative nor a package name, a name the file does not export, a default import or export, an import that names nothing, `import(...)` and `require`, and a module namespace used as a value; a use of what it would have bound reports nothing more ([Rule 12.4](https://typeshade.dev/ko/reference/rules/12-4/)).

규칙 본문과 그 아래 항목은 설계 문서에 적힌 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.

## 근거

TypeShade code is shared the way TypeScript code is (`docs/dx.md` principle 8), and the editor’s TypeScript half reads an import as TypeScript does, so a compiler that refused one would give a second answer about the same program ([Rule 12.7](https://typeshade.dev/ko/reference/rules/12-7/)). A module is one WGSL module whichever file declared what, so scope is TypeScript’s and only the emitted names are the module’s ([Rule 3.2](https://typeshade.dev/ko/reference/rules/3-2/)).

## 출처

changes `0022` and `0024` in `changes/`; [#187](https://github.com/typeshade/typeshade/issues/187); ECMAScript [Modules](https://tc39.es/ecma262/#sec-modules), as TypeScript checks them; Node’s [resolution algorithm](https://nodejs.org/api/esm.html#resolution-algorithm-specification) (`PACKAGE_RESOLVE`, `PACKAGE_EXPORTS_RESOLVE`) for a package; `docs/roadmap.md` item X6.

## 검증 방식

테스트로 확인합니다. 테스트나 게이트 스크립트, CI 워크플로가 이 규칙을 가리키고, 아래 파일 가운데 하나라도 규칙을 더는 가리키지 않으면 추적 검사가 실패합니다.

컴파일러가 이 규칙을 적용하는 곳을 규칙이 직접 적은 내용입니다.

`linkProgram` in `src/compiler/ts/link.ts`, which `compileTsSource` runs for a file that imports, and so `compile()`, the Vite plugin, `tshc check` and the language service; `resolveSpecifier` in `src/compiler/ts/specifier.ts`, the one rule both halves resolve a specifier by, pinned by `src/compiler/ts/specifier.test.ts`; `TS8072 IMPORT`; pinned by `src/compiler/ts/link.test.ts`, which holds `compile()` and the language service to one answer on each program and each refusal, a package’s included; and by the import path of the user journeys (`scripts/user-journey.ts`), whose module imports a package npm installed.

커밋 af54ddad5에서 이 규칙을 확인하는 파일입니다. 파일마다 규칙을 처음 가리키는 줄로 연결했습니다.

- [`scripts/user-journey.ts:24`](https://github.com/typeshade/typeshade/blob/af54ddad5/scripts/user-journey.ts#L24)
- [`src/compiler/ts/link-overloads.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/link-overloads.test.ts#L1)
- [`src/compiler/ts/link.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/link.test.ts#L1)
- [`src/compiler/ts/link.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/link.ts#L1)
- [`src/compiler/ts/pure-alias-host.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/pure-alias-host.test.ts#L1)
- [`src/compiler/ts/pure-alias.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/pure-alias.test.ts#L1)
- [`src/compiler/ts/specifier.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/specifier.test.ts#L1)
- [`src/compiler/ts/specifier.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/specifier.ts#L1)
- [`src/language-service/check.test.ts:237`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/check.test.ts#L237)
- [`src/language-service/program-refusal-location-owner-middle.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/program-refusal-location-owner-middle.test.ts#L1)
- [`src/language-service/program-refusal-location-owner-repeats.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/program-refusal-location-owner-repeats.test.ts#L1)
- [`src/language-service/program-refusal-location-stays-entry.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/program-refusal-location-stays-entry.test.ts#L1)
- [`src/language-service/program-refusal-location-stays-named.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/program-refusal-location-stays-named.test.ts#L1)
- [`src/language-service/program-refusal-location-struct-cli.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/program-refusal-location-struct-cli.test.ts#L1)
- [`src/language-service/program-refusal-location.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/program-refusal-location.test.ts#L1)
- [`src/vite.test.ts:2`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/vite.test.ts#L2)

## 설명하는 절

커밋 af54ddad5의 언어 문서에서 이 규칙을 설명하는 절입니다.

- [§68 Importing another shader module](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#68-importing-another-shader-module)

## 적용하는 오류 코드

규칙이 Enforced by 항목에서 가리키는 진단 코드와, 레지스트리 설명에서 이 규칙을 가리키는 진단 코드입니다.

**[`TS8072`](https://typeshade.dev/ko/reference/errors/ts8072/) `IMPORT`**

컴파일러가 따라가지 않는 import입니다(규칙 3.9). 파일을 가리키지 않거나 이 컴파일이 읽을 수 없는 경로, 셰이더 모듈이 아닌 파일, `node_modules`에 없는 패키지, 패키지의 `exports`가 이름 붙이지 않은 하위 경로, 모듈이 내보내지 않는 이름, 셰이더 모듈에 쓸모없는 형태(기본 import나 export, 아무것도 가져오지 않는 import, `import(...)`, `require`)가 그렇습니다.

## 함께 보기

- [규칙 3.8](https://typeshade.dev/ko/reference/rules/3-8/) 테스트
- [규칙 4.1](https://typeshade.dev/ko/reference/rules/4-1/) 테스트
- [규칙 3.1](https://typeshade.dev/ko/reference/rules/3-1/)
- [규칙 3.2](https://typeshade.dev/ko/reference/rules/3-2/)
- [규칙 12.4](https://typeshade.dev/ko/reference/rules/12-4/)
- [규칙 12.7](https://typeshade.dev/ko/reference/rules/12-7/)
- [설계 규칙](https://typeshade.dev/ko/reference/rules/)
- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

커밋 af54ddad5의 규칙 원문:

- [`docs/language-design.md:247`](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/language-design.md#L247) (설계 문서)
- [`reqs/rules/RULE-0309.md`](https://github.com/typeshade/typeshade/blob/af54ddad5/reqs/rules/RULE-0309.md) (추적 항목)
